<template>
  <div>
    <van-popup :value="show" position="bottom" @input="$emit('update:show', $event)">
      <div class="van-popup-content">
        <div v-for="(item, index) in options" :key="index" :class="active === index && 'active'"
          @click="handleClick(index)">
          <div>
            {{ item.text }}
          </div>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import { Popup } from "vant";

export default {
  name: 'Rate',
  components: {
    [Popup.name]: Popup,
  },
  props: {
    options: {
      type: Array,
      default: () => []
    },
    show: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      active: 2,
    }
  },
  methods: {
    handleClick(index) {
      this.active = index;
      this.$emit('select', this.options[index]);
      this.$emit('update:show', false);
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .van-popup {
  // width: 92% !important;
  background: #121212 !important;
  border-radius: 40px 40px 0 0;

  .van-popup-content {
    padding: 40px 30px;
    padding-bottom: 60px;
    background: #121212;
    color: #fff;
    display: grid;
    gap: 20px;
    position: relative;
    overflow: hidden;


    & div {
      display: flex;
      align-items: center;
      gap: 15px;
      font-size: 28px;
    }

    &>div {
      padding: 10px 20px;
      border-radius: 10px;
    }

    .active {
      // background-color: #191919;
      position: relative;

      &::after {
        content: '';
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        background: url("@/assets/image/Group 7764.png") no-repeat center center;
        width: 40px;
        height: 40px;
      }
    }
  }
}
</style>